package com.jeeplus.mob.web;

import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.mob.service.BuildingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping(value = "/mob/building")
@Api(tags = "楼宇管理")
public class BuildingController {

    @Autowired
    private BuildingService buildingService;

    /**
     * 获取所有楼宇名称及拜访次数
     * @return
     */
    @RequestMapping(value = "getAllBuildingAndVisit",method = RequestMethod.GET)
    @ApiOperation(value = "获取所有楼宇名称及拜访次数")
    public AjaxJson getAllBuildingNameAndVisit(HttpServletRequest request, HttpServletResponse response) {
        AjaxJson ajaxJson = buildingService.getAllBuildingNameAndVisit(request,response);
        return ajaxJson;
    }

    /**
     * 通过楼宇ID获取楼宇信息
     * @param buildingId
     * @return
     */
    @RequestMapping(value = "getBuildingInfoById",method = RequestMethod.GET)
    @ApiOperation(value = "通过Id获取楼宇信息")
    public AjaxJson getBuildingNameAndVisitById(@RequestParam("id") String buildingId) {
        AjaxJson ajaxJson = buildingService.getBuildingNameAndVisitById(buildingId);
        return ajaxJson;
    }

    /**
     * 获取并统计首页所有楼宇（合作中、沟通中、禁止进入）拜访次数统计及位置坐标
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "getBuildingCountVisitsNumber",method = RequestMethod.GET)
    @ApiOperation(value = "统计楼宇拜访次数")
    public AjaxJson getBuildingCountVisitsNumber(HttpServletRequest request,HttpServletResponse response) {
        AjaxJson ajaxJson = buildingService.getBuildingCountVisitsNumber(request,response);
        return ajaxJson;
    }

    /**
     * 获取楼宇详情信息
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "getBuildingInfoByLike",method = RequestMethod.POST)
    @ApiOperation(value = "获取楼宇详情信息")
    public AjaxJson getBuildingInfomationByLike(HttpServletRequest request,HttpServletResponse response) {
        AjaxJson ajaxJson = buildingService.getBuildingInfomationByLike(request,response);
        return ajaxJson;
    }

    /**
     * 获取所有区域信息列表（下拉列表）
     * @return
     */
    @RequestMapping(value = "getAllRegionInfomation",method = RequestMethod.GET)
    @ApiOperation(value = "获取系统所有区域信息列表")
    public AjaxJson getAllRegionInfomation() {
        AjaxJson ajaxJson = buildingService.getAllRegionInfomation();
        return ajaxJson;
    }

    /**
     * 获取所有楼宇状态列表（下拉列表）
     * @return
     */
    @RequestMapping(value = "getAllBuildingStatus",method = RequestMethod.GET)
    @ApiOperation(value = "获取系统所有楼宇状态")
    public AjaxJson getAllBuildingStatus() {
        AjaxJson ajaxJson = buildingService.getAllBuildingStatus();
        return ajaxJson;
    }
}
